<!-- 新闻 -->
<template>
  <div class="page-box h100 display-flex czbj">
    <p class="title-label mb10">新闻列表</p>
    <dxtable
      :dataJson="dataJson"
      :portUrl="portUrl"
      :formJson="formJson"
      :qx="qx"
      ref="databale"
    ></dxtable>
  </div>
</template>
<script lang="ts" setup>
import { Options } from "@vicons/ionicons5";
import dxtable from "../../components/util/dxtable.vue";
import sort from "../../components/util/sort.vue";
import { dxget, dxpost } from "../../util/index";
import { NButton, NImage, NTag } from "naive-ui";
import { h, ref, reactive } from "vue";
const databale = ref();
const initeer = () => {
  databale.value.initDataExpose();
};
let dataJson = [
  {
    title: "标题",
    type: "input",
    val: "",
    icon: "dx-shurukuang",
    span: 24,
    key: "title",
    width: "",
    search: true,
    istable: true,
    required: false,
  },
  {
    title: "封面",
    type: "img",
    val: "",
    icon: "dx-img",
    span: 12,
    key: "cover",
    width: "100",
    search: false,
    istable: true,
    required: false,
  },
  {
    title: "分类",
    type: "select",
    val: "",
    options:[],
    icon: "dx-shurukuang",
    span: 12,
    key: "fenlei",
    width: "200",
    search: true,
    istable: true,
    required: false,
    render: (row) => {
        return dataJson[2].options.filter(a=>a.value==row.fenlei)[0].label
    }
  },
  {
    title: "排序",
    width: 100,
    render: (row) => {
      row.sjk = "jiance"; //数据库
      row.databaseName = "news"; //表名
      return h(sort, {
        row,
        onCallBack: () => {
          initeer();
        },
      });
    },
  },
  {
    title: "添加时间",
    key: "addTime",
    width: 150,
  },
];

const qx = {
  DeletePermissionID: "jcjiancenewsxsedel", //删除
  EditPermissionIdentifier: "jcjiancenewsxsebj", // 编辑
  NewPermissionIdentifier: "jcjiancenewsxsexz", // 新建
  ViewPermissionID: "jcjiancenewsxseck", // 查看
};
const portUrl = "jiance/news/news";

let formJson = reactive([
  {
    title: "标题",
    type: "input",
    val: "",
    icon: "dx-shurukuang",
    span: 24,
    key: "title",
    width: "",
    search: false,
    istable: true,
    required: false,
  },
  {
    title: "封面",
    type: "img",
    val: "",
    icon: "dx-img",
    span: 12,
    key: "cover",
    width: "",
    search: false,
    istable: true,
    required: false,
  },
  {
    title: "分类",
    type: "select",
    val: "",
    options:[],
    icon: "dx-shurukuang",
    span: 12,
    key: "fenlei",
    width: "",
    search: false,
    istable: true,
    required: false,
  },
  {
    title: "详情",
    type: "fwb",
    val: "",
    icon: "dx-m-fuwenben",
    span: 24,
    key: "xq",
    width: "",
    search: false,
    istable: true,
    required: false,
    callBack:(data)=>{
        databale.value.setmodel('miaosu',data)
    }
  },
]);
const czFun = {
  fun: (row) => {
    return [
      h(
        NButton,
        {
          type: "info",
          quaternary: true,
          onClick: async (e) => {},
        },
        "复制代码"
      ),
    ];
  },
};

// 获取字典内容
const xtgxxmfl = async () => {
  const { data }: any = await dxget("dxgjAdmin/getzd", { name: 'jcxinwenfenlei' })
  dataJson[2].options = [
    {
      label: "全部",
      value: ""
    },
    ...data
  ]
  formJson[2].options = data
}
xtgxxmfl()
</script>
<style scoped></style>
